class Solution {
public:
    bool evaluateTree(TreeNode* root) 
    {
        if(root->left == nullptr)
            return root->val;

        bool lhs = evaluateTree(root->left);
        bool rhs = evaluateTree(root->right);

        return root->val == 2 ? lhs | rhs : lhs & rhs;
    }
};